<?

if (null==$listfield1) $listfield1 = "code";
if (null==$listfield2) $listfield2 = "name";
if (null==$listfield3) $listfield3 = "datedetails";
if (null==$listfield4) $listfield4 = "country";
if (null==$listfield5) $listfield5 = "status";
if (null==$listfield6) $listfield6 = "time";
if (null==$listfield7) $listfield7 = "order_index";

if ($label) $exp = "WHERE course='$label'";

if ($action=="search"){

	$Query = "select id, $listfield1, $listfield2, $listfield3, $listfield4, $listfield5, $listfield6, $listfield7 from $table WHERE $listfield1 Like '%$Search%' OR $listfield2 Like '%$Search%'   order by $listfield7 Limit $Offset, $ListNum";

	$Query1 = "select count(*) as total from $table WHERE $listfield1 Like '%$Search%' OR $listfield2 Like  '%$Search%'";

}elseif ($action=="filter")  {

	$Query = "select cs.id, cs.code, cs.name, cs.datedetails, cs.country, cs.status, cs.time, cs.order_index from course_schedule as cs left join course_basic as cb on cs.course=cb.name WHERE cb.type='$type' Limit $Offset, $ListNum";
	//echo $Query;
	$Query1 = "select count(*) from course_schedule as cs left join course_basic as cb on cs.course=cb.name WHERE cb.type='$type'";

}
else{

	$Query = "select id, $listfield1, $listfield2, $listfield3, $listfield4, $listfield5, $listfield6, $listfield7 from $table $exp order by $listfield7 Limit $Offset, $ListNum";

	$Query1 = "select count(*) as total from $table $exp";
	
}


$list = myQuery($Query);


$CountRecord = myQuery($Query1);

$CountNum = $CountRecord[0][0];
$Url="&Searcn=$Search&action=$action";	


print(splitPage($Url,$CountNum));

?>


        <table width="100%" border="0" cellspacing="1" cellpadding="1" class="tb">
          <tr class="tbheader"> 
            <td width="10%">No.</td>
            <td width="20%">Description</td>
			<td width="10%">Date</td>
			<td width="10%">Country</td>
			<td width="10%">Publish</td>
			<td width="10%">Order</td>

			<td width="20%"></td>
          </tr>


<?
if ($list){
	for ($i=0;$i<count($list);$i++){?>
          <tr class="tbcontent1"> 
            <td><?print($list[$i][1])?></td>
            <td><?print($list[$i][2])?></td>
<td align="center"><?print($list[$i][3])?><br><?print($list[$i][6])?></td>
<td align="center"><?print($list[$i][4])?></td>
<td align="center">

<?=$list[$i][5]?>


</td>
<td align="center"><?print($list[$i][7])?></td>

			<td align=center bgcolor="ECECEC">
			<a href="edit.php?id=<?print($list[$i][0])?>&parent_id=<?=$id?>"><img src="<?print($rela_path)?>images/bt_edit.gif" border="0" alt="Edit"></a>
			<a href="delete.php?id=<?print($list[$i][0])?>&parent_id=<?=$id?>"><img src="<?print($rela_path)?>images/bt_delete.gif" border="0" Alt="Delete"></a>
			<a href="enquire.php?id=<?print($list[$i][0])?>&parent_id=<?=$id?>"><img src="<?print($rela_path)?>images/bt_enquiry.gif" border="0" Alt="Enquire"></a>
			<a href="../enrollment/menu.php?id=<?print($list[$i][0])?>"><img src="<?print($rela_path)?>images/bt_enrollment.gif" border="0" Alt="Enrollment"></a>
			<a href="../sharing/menu.php?id=<?print($list[$i][0])?>"><img src="<?print($rela_path)?>images/bt_sharing.gif" border="0" Alt="Graduate's Sharing"></a></td>
          </tr>
<?
	}	
}?>


        </table>

<?print(splitPage($Url,$CountNum))?>
